package com.againstsky.algorithm.sort;

/**
 * Created by agasinst on 2017/9/25.
 */
public class ASort {
    protected  boolean less(Comparable v,Comparable w){
        return v.compareTo(w)<0;
    }

    protected void exch(Comparable[] a,int i,int j){
        Comparable t=a[i];
        a[i]=a[j];
        a[j]=t;
    }

    public boolean isSort(Comparable[] a){
        for (int i=1;i<a.length;i++){
            if(less(a[i],a[i-1]))return false;
        }
        return true;
    }

    public void show(Comparable[] a){
        System.out.print("sort:[");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]+"");
            if(i!=a.length-1){
                System.out.print(",");
            }
        }
        System.out.println("]");
    }
}
